package com.icangya.DAO.impl;

import com.icangya.DAO.IUserBalanceDAO;
import com.icangya.domain.Balance;
import org.springframework.stereotype.Repository;

import java.util.List;
/**
 * author:黄明浜
 * date:2017.10.13 PM: 9:00
 */
@Repository
public class UserBalanceDAOImpl extends BaseDAO<Balance> implements IUserBalanceDAO {

    @Override
    public Balance findByUserId(Long id) {

        String hql="FROM Balance balance WHERE balance.uid = ?";
        List<Balance> balance = (List<Balance>) this.getHibernateTemplate().find(hql,id);

        if (balance == null || balance.size() < 1){
            return null;
        }
        return balance.get(0);
    }
}
